<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/28/028
 * Time: 17:57
 */

namespace app\api\model;
use app\api\service\Token;

class MemberRoleInfo extends BaseModel {
    protected $hidden = ['update_time','delete_time', 'create_time'];

    /**
     * 获取器用户头像
     * @param $value
     * @return string
     */
    public function getHeadimgurlAttr($value)
    {
        return get_img_url($value);
    }

    /**
     * 修改个人信息
     * @param $param
     */
    public static function updateMemberRoleInfoByField($param) {

        $uid = Token::getCurrentUid();

        $value = $param['value'];
        if ($param['field'] == 'birthday') {
            $value = strtotime($value);
        }
//        if ($param['field'] == 'headimgurl') {
//            $value .= '-200';
//        }

        self::where('member_id', '=', $uid)->update([$param['field'] => $value]);

    }
}